package com.einmeer.hfbank.controller;

import com.einmeer.hfbank.service.CardService;
import com.einmeer.hfbank.vo.ResultVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author 芊嵛
 * @date 2024/1/12
 */
@RestController
@RequestMapping("/card")
public class CardController {
    @Resource
    private CardService cardService;

    /**
     * 绑卡
     * @param userId
     * @param cardNumber
     * @param userIDCard
     * @param cardPassword
     * @return
     */
    @PutMapping("/Binding/{userId}/{cardNumber}/{userIDCard}/{cardPassword}")
    @CrossOrigin
    public ResultVo Binding(@PathVariable("userId") Long userId, @PathVariable("cardNumber") Long cardNumber, @PathVariable("userIDCard") String userIDCard, @PathVariable("cardPassword") Integer cardPassword){
        return cardService.Binding(userId, cardNumber, userIDCard, cardPassword);
    }

    /**
     * 显示全部银行卡,活期信息
     * @param userId
     * @return
     */
    @GetMapping("/queryAllCards/{userId}")
    @CrossOrigin
    public ResultVo queryAllCards(@PathVariable("userId") Long userId){
        return cardService.queryAllCards(userId);
    }

    /**
     * 显示银行卡详细信息
     * @param cardNumber
     * @return
     */
    @GetMapping("/queryCard/{cardNumber}")
    @CrossOrigin
    public ResultVo queryCard(@PathVariable("cardNumber") Long cardNumber){
        return cardService.queryCard(cardNumber);
    }

    /**
     * 解绑
     * @param cardNumber
     * @param userPassword
     * @param userId
     * @return
     */
    @PutMapping("/unbind/{cardNumber}/{userPassword}/{userId}")
    @CrossOrigin
    public ResultVo unbind(@PathVariable("cardNumber") Long cardNumber, @PathVariable("userPassword") String userPassword, @PathVariable("userId") Long userId){
        return cardService.unbind(cardNumber, userPassword, userId);
    }
}
